-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
alter TRIGGER AlertQueuePrint_TRIGG	
   ON  [dsiTransactionLog]
   AFTER INSERT
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    if exists( select 1 from dbo.dsiTransactionLog where FunctionName='QueuePrint') 
    
    Begin
		exec msdb.dbo.sp_send_dbmail 
		@profile_name='Default',   
		@recipients = 'ychoi@farmerbros.com',
		@body = 'QUEUE print was called ',
		@subject = 'Automated Success Message',
		@query='SELECT  [DATAIn]    ,[ScriptID] FROM dsiTransactionLog where FunctionName="QueuePrint"';
                  
	END
END
GO
